Skip to content

Add new copy dialog when there are save issues detected (#3637)#3754

Merged
endrift merged 2 commits intomgba-emu:masterfrom
endrift:save-warn-ux
Apr 4, 2026
Merged

Add new copy dialog when there are save issues detected (#3637)#3754
endrift merged 2 commits intomgba-emu:masterfrom
endrift:save-warn-ux

Conversation

@endrift
Copy link
Copy Markdown
Member

@endrift endrift commented Apr 3, 2026

Can you review this @ahigerd?

@endrift endrift linked an issue Apr 3, 2026 that may be closed by this pull request
@ahigerd
Copy link
Copy Markdown
Contributor

ahigerd commented Apr 3, 2026

With pleasure! 👀

QMessageBox error;
error.setIcon(QMessageBox::Critical);
error.setWindowTitle(title);
error.setText(tr("%1 Would you like to move the ROM to a different location? If you don't, this will likely lead to data loss (e.g. saves, screenshots, etc.).").arg(summary));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/move/copy/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stylistically I would also consider %1\n\n for readability.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might also suggest summary + "\n\n" + tr("...") to keep the first line out of the translation, but that's entirely optional.

if (ok) {
return newPath;
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps attempt to delete the destination file if it was created but not fully populated? I can imagine an edge case where you run into a disk-full condition and the partial ROM is eating up the last megabyte of space on a tiny SD card.

}
if (bad) {
QString newPath = saveFailed(vf, tr("Temporary file loaded"),
tr("The ROM appears to be loaded from a temporary directory, perhaps automatically extracted from an archive."),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering our userbase, perhaps "archive (e.g. zip file)"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I had tried to figure out how to make that clearer. I guess that works.

QMessageBox retry;
retry.setIcon(QMessageBox::Critical);
retry.setWindowTitle(tr("Copy failed"));
retry.setText(tr("Failed to copy ROM. Do you want to try again?"));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The engineer in me would like to be able to report why the copy failed. QIODevice::errorString() might be a good place to start, though you might have better luck with QFileDevice::error() mapping into something where you can control/localize the messages.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to do that, at least not yet.

}

auto retry = [this]() {
QMessageBox retry;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I broadly prefer to use QMessageBox::critical() over constructing the object longhand if I'm going to be using exec() instead of open(). Your codebase, your style preference, but I think that's how it's been done elsewhere as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the signature is so long that you kinda have to know what the order is, but it is what I do already elsewhere in the codebase I suppose.

}

QString CoreManager::saveFailed(VFile* vf, const QString& title, const QString& summary, const QString& filter) {
QMessageBox error;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto what I said below about using the static method.

Copy link
Copy Markdown
Contributor

@ahigerd ahigerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly style comments. One point of functionality you might consider, but I would be okay with merging this as-is.

@endrift endrift merged commit 80871fc into mgba-emu:master Apr 4, 2026
1 check was pending
@endrift endrift deleted the save-warn-ux branch April 4, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve UX when loading ROMs from a temporary/non-writable path

2 participants